package com.knowif.service;

import com.knowif.dao.OfferMapper;
import com.knowif.pojo.Offer;
import com.knowif.pojo.OfferExample;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author ：Xh
 * @date ：Created in 2019/5/4 0004 21:28
 */
@Service
public class Offer_service {

    @Autowired
    private OfferMapper offerMapper;

    /**
     * 条件统计
     * @param offerExample
     * @return
     */
    public int countOfferByParams(OfferExample offerExample){
        return offerMapper.countByExample(offerExample);
    }

    /**
     * 根据条件删除 offer
     * @param offerExample
     * @return
     */
    public int deleteOfferByParams(OfferExample offerExample){
        return offerMapper.deleteByExample(offerExample);
    }

    /**
     * 保存不为空的offer
     * @param offer
     * @return
     */
    public int saveOfferNotNull(Offer offer){
        return offerMapper.insertSelective(offer);
    }

    /**
     * 通过主键查询Offer
     * @param primaryKey
     * @return
     */
    public Offer selectOfferById(int primaryKey){
        return offerMapper.selectByPrimaryKey(primaryKey);
    }

    /**
     * 通过参数更新不为空的
     * @param offer
     * @param offerExample
     * @return
     */
    public int updateOfferNotNullByParams(Offer offer, OfferExample offerExample){
        return offerMapper.updateByExampleSelective(offer, offerExample);
    }

    /**
     * 通过参数更新所有
     * @param offer
     * @param offerExample
     * @return
     */
    public int updateOfferByParams(Offer offer, OfferExample offerExample){
        return offerMapper.updateByExample(offer, offerExample);
    }



    /**
     * Offer条件查询
     * @param offerExample
     * @return
     */
    public List<Offer> selectOffer(OfferExample offerExample){
        return offerMapper.selectByExample(offerExample);
    }

    /**
     * 插入offer
     * @param offer
     * @return
     */
    public int saveOffer(Offer offer){
        return offerMapper.insert(offer);
    }

    /**
     * 更新不为空的offer属性
     * @param offer
     * @return
     */
    public int updateOfferNotNull(Offer offer){
        return offerMapper.updateByPrimaryKeySelective(offer);
    }

    /**
     * 更新所有offer属性
     * @param offer
     * @return
     */
    public int updateOffer(Offer offer){
        return offerMapper.updateByPrimaryKey(offer);
    }

    /**
     * 删除offer
     * @param offerId
     */
    public int deleteOffer(int offerId){
        return offerMapper.deleteByPrimaryKey(offerId);
    }
}
